using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using SpatialApp;

namespace ICP_MS.Plugin.LA300;

public class FormDistribution : Form
{
	private ExperimentDatas experiment = null;

	private ExperimentDB db = null;

	private SamplesInfos sample = null;

	private IsotopeInfos isotope = null;

	public double zoom = 1.0;

	private IContainer components = null;

	private GroupBox groupBox1;

	private TreeView treeView1;

	private Label lblSample;

	private Label label1;

	private GroupBox groupBox2;

	private CheckBox checkBox2;

	private Label lblElement;

	private CheckBox checkBox1;

	private Label lblZoom;

	private TrackBar trackBar1;

	private Button btnDraw;

	private GroupBox groupBox3;

	private TextBox txtMax;

	private Label label6;

	private TextBox txtMin;

	private Label label7;

	private DataGridView dataGridView1;

	private ProgressBar progressBar1;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;

	private Label label3;

	private TextBox txtH;

	private TextBox txtW;

	private Label label2;

	private TextBox txtSigma;

	private Label label5;

	private TextBox txtAverage;

	private Label label4;

	private CheckBox chkExclude;

	private FlowLayoutPanel flowLayoutPanel1;

	private GroupBox groupBox4;

	private DataGridViewTextBoxColumn colColor;

	private DataGridViewTextBoxColumn colValue;

	public void SetParams(ExperimentDatas experiment, ExperimentDB db)
	{
		this.experiment = experiment;
		this.db = db;
	}

	public FormDistribution()
	{
		InitializeComponent();
	}

	private void FormDistribution_Load(object sender, EventArgs e)
	{
		ApplyResources();
		base.WindowState = FormWindowState.Maximized;
		SetupSampleInfos();
		BindColors();
	}

	private void ApplyResources()
	{
		groupBox1.Text = Lang.Txt("LA300.Text3");
		label1.Text = Lang.Txt("LA300.Text4");
		btnDraw.Text = Lang.Txt("LA300.Text5");
		checkBox1.Text = Lang.Txt("LA300.Text6");
		checkBox2.Text = Lang.Txt("LA300.Text7");
		chkExclude.Text = Lang.Txt("LA300.Text8");
		groupBox3.Text = Lang.Txt("LA300.Text9");
		label7.Text = Lang.Txt("LA300.Text10");
		label6.Text = Lang.Txt("LA300.Text11");
		label4.Text = Lang.Txt("LA300.Text12");
		groupBox4.Text = Lang.Txt("LA300.Text13");
		label2.Text = Lang.Txt("LA300.Text14");
		label3.Text = Lang.Txt("LA300.Text15");
		colColor.HeaderText = Lang.Txt("LA300.Text16");
		colValue.HeaderText = Lang.Txt("LA300.Text17");
	}

	public void UpdateSelectedIsotopes(object sender, EventArgs e)
	{
		SetupSampleInfos();
	}

	public void UpdateSelectedSamples(object sender, EventArgs e)
	{
		SetupSampleInfos();
	}

	private void SetupSampleInfos()
	{
		treeView1.Nodes.Clear();
		TreeNode node = treeView1.Nodes.Add("--<NONE>--");
		node.Tag = null;
		foreach (SamplesInfos sample in experiment.Samples)
		{
			node = treeView1.Nodes.Add(sample.label);
			node.Tag = sample;
			foreach (IsotopeInfos isotope in experiment.Isotopes)
			{
				TreeNode subNode = node.Nodes.Add(isotope.symbol);
				subNode.Tag = isotope;
			}
		}
		treeView1.ExpandAll();
	}

	private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
	{
		if (e.Node.Tag != null)
		{
			if (e.Node.Tag is IsotopeInfos tmpIsotope)
			{
				isotope = tmpIsotope;
				sample = e.Node.Parent.Tag as SamplesInfos;
			}
			else
			{
				if (e.Node.Tag is SamplesInfos tmpSample)
				{
					sample = tmpSample;
				}
				isotope = null;
			}
			if (sample != null)
			{
				lblSample.Text = sample.label;
			}
		}
		else
		{
			isotope = null;
			sample = null;
		}
		btnDraw.PerformClick();
	}

	private void btnDraw_Click(object sender, EventArgs e)
	{
		flowLayoutPanel1.Controls.Clear();
		int nwidth = Convert.ToInt32(txtW.Text);
		int nheight = Convert.ToInt32(txtH.Text);
		if (sample == null || sample.status != 1)
		{
			return;
		}
		progressBar1.Visible = true;
		progressBar1.Maximum = experiment.Isotopes.Count;
		Cursor = Cursors.WaitCursor;
		Task.Factory.StartNew(delegate
		{
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Expected O, but got Unknown
			foreach (IsotopeInfos isotopee in experiment.Isotopes)
			{
				if (isotope == null || !(isotope.symbol != isotopee.symbol))
				{
					IEnumerable<IntegerRegions> regions = experiment.IntegerRegions.Where((IntegerRegions region) => region.SampleId == sample.guid);
					if (regions.Any())
					{
						IntegerRegions region2 = regions.First();
						IEnumerable<TimeSpectrum> source = experiment.TimeSpectrums.Where((TimeSpectrum spectrum) => spectrum.SampleId == sample.guid && spectrum.Symbol == isotopee.symbol && regions.Any((IntegerRegions r) => r.Mains == spectrum.RunIndex + 1) && !isotopee.inter && spectrum.isTest);
						if (source.Count() > 2)
						{
							int num = source.Count();
							int num2 = (region2.End - region2.Start) * 4;
							List<double> buf = new List<double>();
							double max = double.MinValue;
							double min = double.MaxValue;
							for (int i = 0; i < source.Count(); i++)
							{
								TimeSpectrum spectrum2 = source.ElementAt(i);
								if (chkExclude.Checked)
								{
									IEnumerable<AnalyseInfos> enumerable = experiment.Results.Where((AnalyseInfos ress) => ress.sampleId == sample.guid && ress.number == spectrum2.RunIndex && ress.symbol == spectrum2.Symbol);
									if (enumerable != null && enumerable.Count() > 0 && enumerable.First().exclude)
									{
										num--;
										continue;
									}
								}
								List<double> list = experiment.CalculateTimeSpectrumConcentration(new List<double>(spectrum2.Intensity), sample, isotopee, spectrum2.RunIndex);
								for (int j = 0; j < list.Count; j++)
								{
									list[j] = double.Parse(list[j].ToString("f3"));
								}
								IEnumerable<double> source2 = list.Where((double data, int index) => spectrum2.Time[index] >= (double)region2.Start && spectrum2.Time[index] <= (double)region2.End);
								if (source2.Count() != 0)
								{
									max = Math.Max(max, source2.Max());
									min = Math.Min(min, source2.Min());
									Interpolation val = new Interpolation(spectrum2.Time, list);
									for (int k = 0; k < num2; k++)
									{
										buf.Add(val.Interpolate((double)region2.Start + (double)k * 0.25));
									}
								}
							}
							double num3 = CalculateDeviation(buf.ToArray());
							double sd3 = 3.0 * Math.Pow(num3, 0.5);
							Invoke((MethodInvoker)delegate
							{
								txtAverage.Text = buf.Average().ToString("F0");
								txtSigma.Text = sd3.ToString("F0");
							});
							double[] array = InterpolateBuf.Interpolate(buf.ToArray(), num2, num, nwidth, nheight);
							if (!checkBox2.Checked || txtMin.Text == "")
							{
								min = array.Min();
								Invoke((MethodInvoker)delegate
								{
									txtMin.Text = min.ToString("F0");
								});
							}
							else
							{
								min = Convert.ToSingle(txtMin.Text);
							}
							if (!checkBox2.Checked || txtMax.Text == "")
							{
								max = array.Max();
								Invoke((MethodInvoker)delegate
								{
									txtMax.Text = max.ToString("F0");
								});
							}
							else
							{
								max = Convert.ToSingle(txtMax.Text);
							}
							if (!checkBox2.Checked)
							{
								ColorDistribution.map.InitColors(min, max);
								BindColors();
							}
							Bitmap image = ColorDistribution.GetImage(array, nwidth, nheight);
							if (image != null)
							{
								ColorMapCntl map = new ColorMapCntl();
								map.Caption = isotopee.symbol;
								map.Zoom = (float)zoom;
								map.Width = Convert.ToInt32(zoom * (double)nwidth + 0.5) + 5;
								map.Height = Convert.ToInt32(zoom * (double)nheight + 0.5) + 32;
								map.Image = image;
								Invoke((EventHandler)delegate
								{
									flowLayoutPanel1.Controls.Add(map);
								});
							}
						}
						Invoke((MethodInvoker)delegate
						{
							progressBar1.PerformStep();
						});
					}
				}
			}
			Invoke((MethodInvoker)delegate
			{
				progressBar1.Value = 0;
				progressBar1.Visible = false;
				Cursor = Cursors.Arrow;
			});
		});
	}

	private double CalculateAverage(double[] values)
	{
		if (values != null && values.Length != 0)
		{
			return values.Average();
		}
		return double.NaN;
	}

	private double CalculateDeviation(double[] values)
	{
		if (values == null)
		{
			return double.NaN;
		}
		double sum = 0.0;
		double sum2 = 0.0;
		int counter = 0;
		foreach (double val in values)
		{
			if (!double.IsNaN(val))
			{
				sum += val;
				sum2 += val * val;
				counter++;
			}
		}
		if (counter < 2)
		{
			return double.NaN;
		}
		return Math.Sqrt(((double)counter * sum2 - sum * sum) / (double)counter / (double)(counter - 1));
	}

	private void checkBox1_CheckedChanged(object sender, EventArgs e)
	{
		ColorDistribution.map.Gradual = checkBox1.Checked;
	}

	private void BindColors()
	{
		dataGridView1.AutoGenerateColumns = false;
		if (dataGridView1.DataSource == null)
		{
			Invoke((EventHandler)delegate
			{
				dataGridView1.DataSource = ColorDistribution.map.Colors;
			});
			return;
		}
		Invoke((EventHandler)delegate
		{
			BindingContext[dataGridView1.DataSource].SuspendBinding();
			dataGridView1.DataSource = null;
			dataGridView1.DataSource = ColorDistribution.map.Colors;
			BindingContext[dataGridView1.DataSource].ResumeBinding();
		});
	}

	private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
	{
		if (e.RowIndex >= 0 && e.ColumnIndex == colValue.Index)
		{
			ColorMap.ColorPoint color = ColorDistribution.map.Colors[e.RowIndex];
			dataGridView1.Rows[e.RowIndex].Cells[0].Style.BackColor = Color.FromArgb(color.r, color.g, color.b);
		}
	}

	private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
	{
		if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
		{
			ColorDialog dlg = new ColorDialog();
			ColorMap.ColorPoint color = ColorDistribution.map.Colors[e.RowIndex];
			dlg.Color = Color.FromArgb(color.r, color.g, color.b);
			if (dlg.ShowDialog() == DialogResult.OK)
			{
				color.r = dlg.Color.R;
				color.g = dlg.Color.G;
				color.b = dlg.Color.B;
				dataGridView1.Refresh();
			}
		}
	}

	private void dataGridView1_MouseDown(object sender, MouseEventArgs e)
	{
		if (e.Button != MouseButtons.Right)
		{
			return;
		}
		ContextMenu menu = new ContextMenu();
		menu.MenuItems.Add(Lang.Txt("FormScanLA.Add"), delegate
		{
			ColorDialog colorDialog = new ColorDialog();
			if (colorDialog.ShowDialog() == DialogResult.OK)
			{
				ColorDistribution.map.Colors.Add(new ColorMap.ColorPoint(colorDialog.Color.R, colorDialog.Color.G, colorDialog.Color.B, 1f));
			}
			BindColors();
		});
		menu.MenuItems.Add(Lang.Txt("FormScanLA.Delete"), delegate
		{
			if (dataGridView1.SelectedCells.Count != 0)
			{
				int rowIndex = dataGridView1.SelectedCells[0].RowIndex;
				ColorDistribution.map.Colors.RemoveAt(rowIndex);
				BindColors();
			}
		});
		menu.Show(dataGridView1, e.Location);
	}

	private void trackBar1_Scroll(object sender, EventArgs e)
	{
		zoom = decimal.ToSingle(trackBar1.Value) / 100f;
		lblZoom.Text = $"{trackBar1.Value}%";
		btnDraw.PerformClick();
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
		this.groupBox1 = new System.Windows.Forms.GroupBox();
		this.treeView1 = new System.Windows.Forms.TreeView();
		this.lblSample = new System.Windows.Forms.Label();
		this.label1 = new System.Windows.Forms.Label();
		this.groupBox2 = new System.Windows.Forms.GroupBox();
		this.checkBox2 = new System.Windows.Forms.CheckBox();
		this.lblElement = new System.Windows.Forms.Label();
		this.chkExclude = new System.Windows.Forms.CheckBox();
		this.checkBox1 = new System.Windows.Forms.CheckBox();
		this.lblZoom = new System.Windows.Forms.Label();
		this.trackBar1 = new System.Windows.Forms.TrackBar();
		this.btnDraw = new System.Windows.Forms.Button();
		this.groupBox3 = new System.Windows.Forms.GroupBox();
		this.txtSigma = new System.Windows.Forms.TextBox();
		this.label5 = new System.Windows.Forms.Label();
		this.txtAverage = new System.Windows.Forms.TextBox();
		this.label4 = new System.Windows.Forms.Label();
		this.txtMax = new System.Windows.Forms.TextBox();
		this.label6 = new System.Windows.Forms.Label();
		this.txtMin = new System.Windows.Forms.TextBox();
		this.label7 = new System.Windows.Forms.Label();
		this.label3 = new System.Windows.Forms.Label();
		this.txtH = new System.Windows.Forms.TextBox();
		this.txtW = new System.Windows.Forms.TextBox();
		this.label2 = new System.Windows.Forms.Label();
		this.dataGridView1 = new System.Windows.Forms.DataGridView();
		this.colColor = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colValue = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.progressBar1 = new System.Windows.Forms.ProgressBar();
		this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
		this.groupBox4 = new System.Windows.Forms.GroupBox();
		this.groupBox1.SuspendLayout();
		this.groupBox2.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.trackBar1).BeginInit();
		this.groupBox3.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.dataGridView1).BeginInit();
		this.groupBox4.SuspendLayout();
		base.SuspendLayout();
		this.groupBox1.Controls.Add(this.treeView1);
		this.groupBox1.Dock = System.Windows.Forms.DockStyle.Left;
		this.groupBox1.Location = new System.Drawing.Point(0, 0);
		this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.groupBox1.Name = "groupBox1";
		this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.groupBox1.Size = new System.Drawing.Size(272, 744);
		this.groupBox1.TabIndex = 0;
		this.groupBox1.TabStop = false;
		this.groupBox1.Text = "样品";
		this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
		this.treeView1.Location = new System.Drawing.Point(4, 22);
		this.treeView1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.treeView1.Name = "treeView1";
		this.treeView1.Size = new System.Drawing.Size(264, 718);
		this.treeView1.TabIndex = 0;
		this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(treeView1_AfterSelect);
		this.lblSample.AutoSize = true;
		this.lblSample.Location = new System.Drawing.Point(422, 22);
		this.lblSample.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.lblSample.Name = "lblSample";
		this.lblSample.Size = new System.Drawing.Size(31, 15);
		this.lblSample.TabIndex = 2;
		this.lblSample.Text = "...";
		this.label1.AutoSize = true;
		this.label1.Location = new System.Drawing.Point(292, 22);
		this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(82, 15);
		this.label1.TabIndex = 1;
		this.label1.Text = "当前样品：";
		this.groupBox2.Controls.Add(this.checkBox2);
		this.groupBox2.Controls.Add(this.lblElement);
		this.groupBox2.Controls.Add(this.chkExclude);
		this.groupBox2.Controls.Add(this.checkBox1);
		this.groupBox2.Controls.Add(this.lblZoom);
		this.groupBox2.Controls.Add(this.trackBar1);
		this.groupBox2.Controls.Add(this.btnDraw);
		this.groupBox2.Location = new System.Drawing.Point(280, 51);
		this.groupBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.groupBox2.Name = "groupBox2";
		this.groupBox2.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.groupBox2.Size = new System.Drawing.Size(311, 152);
		this.groupBox2.TabIndex = 54;
		this.groupBox2.TabStop = false;
		this.checkBox2.AutoSize = true;
		this.checkBox2.Location = new System.Drawing.Point(97, 78);
		this.checkBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.checkBox2.Name = "checkBox2";
		this.checkBox2.Size = new System.Drawing.Size(59, 19);
		this.checkBox2.TabIndex = 53;
		this.checkBox2.Text = "阈值";
		this.checkBox2.UseVisualStyleBackColor = true;
		this.lblElement.Location = new System.Drawing.Point(175, 16);
		this.lblElement.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.lblElement.Name = "lblElement";
		this.lblElement.Size = new System.Drawing.Size(124, 35);
		this.lblElement.TabIndex = 52;
		this.lblElement.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
		this.chkExclude.AutoSize = true;
		this.chkExclude.Location = new System.Drawing.Point(179, 78);
		this.chkExclude.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.chkExclude.Name = "chkExclude";
		this.chkExclude.Size = new System.Drawing.Size(119, 19);
		this.chkExclude.TabIndex = 7;
		this.chkExclude.Text = "剔除异常数据";
		this.chkExclude.UseVisualStyleBackColor = true;
		this.chkExclude.CheckedChanged += new System.EventHandler(checkBox1_CheckedChanged);
		this.checkBox1.AutoSize = true;
		this.checkBox1.Location = new System.Drawing.Point(21, 78);
		this.checkBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.checkBox1.Name = "checkBox1";
		this.checkBox1.Size = new System.Drawing.Size(59, 19);
		this.checkBox1.TabIndex = 7;
		this.checkBox1.Text = "渐变";
		this.checkBox1.UseVisualStyleBackColor = true;
		this.checkBox1.CheckedChanged += new System.EventHandler(checkBox1_CheckedChanged);
		this.lblZoom.AutoSize = true;
		this.lblZoom.Location = new System.Drawing.Point(253, 128);
		this.lblZoom.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.lblZoom.Name = "lblZoom";
		this.lblZoom.Size = new System.Drawing.Size(39, 15);
		this.lblZoom.TabIndex = 51;
		this.lblZoom.Text = "100%";
		this.trackBar1.AutoSize = false;
		this.trackBar1.LargeChange = 50;
		this.trackBar1.Location = new System.Drawing.Point(31, 121);
		this.trackBar1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.trackBar1.Maximum = 500;
		this.trackBar1.Minimum = 1;
		this.trackBar1.Name = "trackBar1";
		this.trackBar1.Size = new System.Drawing.Size(215, 21);
		this.trackBar1.SmallChange = 10;
		this.trackBar1.TabIndex = 50;
		this.trackBar1.Value = 100;
		this.trackBar1.Scroll += new System.EventHandler(trackBar1_Scroll);
		this.btnDraw.Location = new System.Drawing.Point(23, 25);
		this.btnDraw.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.btnDraw.Name = "btnDraw";
		this.btnDraw.Size = new System.Drawing.Size(123, 34);
		this.btnDraw.TabIndex = 2;
		this.btnDraw.Text = "刷新";
		this.btnDraw.UseVisualStyleBackColor = true;
		this.btnDraw.Click += new System.EventHandler(btnDraw_Click);
		this.groupBox3.Controls.Add(this.txtSigma);
		this.groupBox3.Controls.Add(this.label5);
		this.groupBox3.Controls.Add(this.txtAverage);
		this.groupBox3.Controls.Add(this.label4);
		this.groupBox3.Controls.Add(this.txtMax);
		this.groupBox3.Controls.Add(this.label6);
		this.groupBox3.Controls.Add(this.txtMin);
		this.groupBox3.Controls.Add(this.label7);
		this.groupBox3.Location = new System.Drawing.Point(283, 211);
		this.groupBox3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.groupBox3.Name = "groupBox3";
		this.groupBox3.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.groupBox3.Size = new System.Drawing.Size(311, 155);
		this.groupBox3.TabIndex = 55;
		this.groupBox3.TabStop = false;
		this.groupBox3.Text = "数据统计";
		this.txtSigma.Enabled = false;
		this.txtSigma.Location = new System.Drawing.Point(111, 120);
		this.txtSigma.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.txtSigma.Name = "txtSigma";
		this.txtSigma.Size = new System.Drawing.Size(108, 25);
		this.txtSigma.TabIndex = 6;
		this.label5.AutoSize = true;
		this.label5.Location = new System.Drawing.Point(60, 124);
		this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.label5.Name = "label5";
		this.label5.Size = new System.Drawing.Size(38, 15);
		this.label5.TabIndex = 5;
		this.label5.Text = "3σ:";
		this.txtAverage.Enabled = false;
		this.txtAverage.Location = new System.Drawing.Point(111, 86);
		this.txtAverage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.txtAverage.Name = "txtAverage";
		this.txtAverage.Size = new System.Drawing.Size(108, 25);
		this.txtAverage.TabIndex = 6;
		this.txtAverage.Text = "0";
		this.label4.AutoSize = true;
		this.label4.Location = new System.Drawing.Point(36, 90);
		this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.label4.Name = "label4";
		this.label4.Size = new System.Drawing.Size(60, 15);
		this.label4.TabIndex = 5;
		this.label4.Text = "平均值:";
		this.txtMax.Enabled = false;
		this.txtMax.Location = new System.Drawing.Point(111, 52);
		this.txtMax.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.txtMax.Name = "txtMax";
		this.txtMax.Size = new System.Drawing.Size(108, 25);
		this.txtMax.TabIndex = 6;
		this.label6.AutoSize = true;
		this.label6.Location = new System.Drawing.Point(36, 56);
		this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.label6.Name = "label6";
		this.label6.Size = new System.Drawing.Size(60, 15);
		this.label6.TabIndex = 5;
		this.label6.Text = "最大值:";
		this.txtMin.Enabled = false;
		this.txtMin.Location = new System.Drawing.Point(111, 18);
		this.txtMin.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.txtMin.Name = "txtMin";
		this.txtMin.Size = new System.Drawing.Size(108, 25);
		this.txtMin.TabIndex = 4;
		this.label7.AutoSize = true;
		this.label7.Location = new System.Drawing.Point(36, 21);
		this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.label7.Name = "label7";
		this.label7.Size = new System.Drawing.Size(60, 15);
		this.label7.TabIndex = 3;
		this.label7.Text = "最小值:";
		this.label3.AutoSize = true;
		this.label3.Location = new System.Drawing.Point(25, 61);
		this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.label3.Name = "label3";
		this.label3.Size = new System.Drawing.Size(75, 15);
		this.label3.TabIndex = 9;
		this.label3.Text = "绘图宽度:";
		this.txtH.Location = new System.Drawing.Point(112, 51);
		this.txtH.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.txtH.Name = "txtH";
		this.txtH.Size = new System.Drawing.Size(108, 25);
		this.txtH.TabIndex = 10;
		this.txtH.Text = "200";
		this.txtW.Location = new System.Drawing.Point(109, 18);
		this.txtW.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.txtW.Name = "txtW";
		this.txtW.Size = new System.Drawing.Size(108, 25);
		this.txtW.TabIndex = 8;
		this.txtW.Text = "200";
		this.label2.AutoSize = true;
		this.label2.Location = new System.Drawing.Point(25, 21);
		this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(75, 15);
		this.label2.TabIndex = 7;
		this.label2.Text = "绘图长度:";
		this.dataGridView1.AllowUserToAddRows = false;
		this.dataGridView1.AllowUserToDeleteRows = false;
		this.dataGridView1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
		this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		this.dataGridView1.Columns.AddRange(this.colColor, this.colValue);
		this.dataGridView1.Location = new System.Drawing.Point(281, 471);
		this.dataGridView1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.dataGridView1.Name = "dataGridView1";
		this.dataGridView1.RowHeadersVisible = false;
		this.dataGridView1.RowHeadersWidth = 51;
		this.dataGridView1.RowTemplate.Height = 23;
		this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
		this.dataGridView1.Size = new System.Drawing.Size(309, 269);
		this.dataGridView1.TabIndex = 57;
		this.dataGridView1.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(dataGridView1_CellFormatting);
		this.dataGridView1.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(dataGridView1_CellMouseDoubleClick);
		this.dataGridView1.MouseDown += new System.Windows.Forms.MouseEventHandler(dataGridView1_MouseDown);
		this.colColor.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.colColor.HeaderText = "颜色";
		this.colColor.MinimumWidth = 6;
		this.colColor.Name = "colColor";
		this.colColor.ReadOnly = true;
		this.colColor.Resizable = System.Windows.Forms.DataGridViewTriState.True;
		this.colColor.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.colValue.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.colValue.DataPropertyName = "val";
		dataGridViewCellStyle1.Format = "N3";
		dataGridViewCellStyle1.NullValue = null;
		this.colValue.DefaultCellStyle = dataGridViewCellStyle1;
		this.colValue.HeaderText = "值";
		this.colValue.MinimumWidth = 6;
		this.colValue.Name = "colValue";
		this.progressBar1.Location = new System.Drawing.Point(599, 21);
		this.progressBar1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.progressBar1.Name = "progressBar1";
		this.progressBar1.Size = new System.Drawing.Size(721, 30);
		this.progressBar1.TabIndex = 59;
		this.progressBar1.Visible = false;
		this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn1.HeaderText = "Color";
		this.dataGridViewTextBoxColumn1.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
		this.dataGridViewTextBoxColumn1.ReadOnly = true;
		this.dataGridViewTextBoxColumn1.Resizable = System.Windows.Forms.DataGridViewTriState.True;
		this.dataGridViewTextBoxColumn1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn2.DataPropertyName = "val";
		this.dataGridViewTextBoxColumn2.HeaderText = "Value";
		this.dataGridViewTextBoxColumn2.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
		this.flowLayoutPanel1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.flowLayoutPanel1.AutoScroll = true;
		this.flowLayoutPanel1.Location = new System.Drawing.Point(601, 62);
		this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.flowLayoutPanel1.Name = "flowLayoutPanel1";
		this.flowLayoutPanel1.Size = new System.Drawing.Size(731, 678);
		this.flowLayoutPanel1.TabIndex = 60;
		this.groupBox4.Controls.Add(this.txtH);
		this.groupBox4.Controls.Add(this.txtW);
		this.groupBox4.Controls.Add(this.label3);
		this.groupBox4.Controls.Add(this.label2);
		this.groupBox4.Location = new System.Drawing.Point(283, 374);
		this.groupBox4.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.groupBox4.Name = "groupBox4";
		this.groupBox4.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.groupBox4.Size = new System.Drawing.Size(307, 90);
		this.groupBox4.TabIndex = 61;
		this.groupBox4.TabStop = false;
		this.groupBox4.Text = "绘图";
		base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 15f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(1336, 744);
		base.Controls.Add(this.groupBox4);
		base.Controls.Add(this.flowLayoutPanel1);
		base.Controls.Add(this.progressBar1);
		base.Controls.Add(this.dataGridView1);
		base.Controls.Add(this.groupBox3);
		base.Controls.Add(this.groupBox2);
		base.Controls.Add(this.lblSample);
		base.Controls.Add(this.label1);
		base.Controls.Add(this.groupBox1);
		base.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		base.Name = "FormDistribution";
		base.ShowIcon = false;
		this.Text = "FormDistribution";
		base.Load += new System.EventHandler(FormDistribution_Load);
		this.groupBox1.ResumeLayout(false);
		this.groupBox2.ResumeLayout(false);
		this.groupBox2.PerformLayout();
		((System.ComponentModel.ISupportInitialize)this.trackBar1).EndInit();
		this.groupBox3.ResumeLayout(false);
		this.groupBox3.PerformLayout();
		((System.ComponentModel.ISupportInitialize)this.dataGridView1).EndInit();
		this.groupBox4.ResumeLayout(false);
		this.groupBox4.PerformLayout();
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
